package com.yfqy.app.modules.promotion.resource;

import com.github.pagehelper.PageInfo;
import com.yfqy.app.domain.vo.ResultVO;
import com.yfqy.app.modules.promotion.dto.PromotionQueryDTO;
import com.yfqy.app.modules.promotion.service.PromotionService;
import com.yfqy.app.modules.promotion.vo.PromotionVO;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * 商品促销活动
 */
@RestController
@RequestMapping("/api/internal/promotion")
public class PromotionController {

    @Resource
    private PromotionService promotionService;


    /**
     * 促销活动分页列表
     *
     * @param queryDTO
     * @return
     */
    @PostMapping("/page")
    public ResultVO<PageInfo<PromotionVO>> queryPromotionPage(@RequestBody PromotionQueryDTO queryDTO) {
        PageInfo<PromotionVO> page = promotionService.queryPromotionPage(queryDTO);
        return ResultVO.data(page);
    }

    /**
     * 促销活动详情
     *
     * @param id
     * @return
     */
    @GetMapping("/detail")
    public ResultVO<PromotionVO> queryPromotionDetail(@RequestParam("id") Long id) {
        return ResultVO.data(promotionService.queryPromotionDetail(id));
    }

}
